package com.bailian.spring.ioc.anno_dl.config;

import com.bailian.spring.ioc.anno_dl.bean.Cat;
import com.bailian.spring.ioc.anno_dl.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author gaoxu
 * date: Created on 2021/10/28 下午6:10
 */

@Configuration
@ComponentScan(basePackages = {"com.bailian.spring.ioc.anno_dl.bean","com.bailian.spring.ioc.anno_dl.bean2"})
public class QuickstartConfiguration {
    /**
     * 可以理解向IOC 容器注册一个类型为Person,id是person的bean,方法返回的类型代表
     * 注册的类型,方法名代表Bean的id
     *
     * @return
     */
    @Bean
    public Person person() {
        Person person = new Person();
        person.setName("张三");
        person.setAge(12);
        return person;
    }

    @Bean
    public Cat cat() {
        Cat cat = new Cat();
        cat.setMaster(person());
        cat.setName("小花猫");
        return cat;
    }
}
